package com.zq.it.cms.web.back;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zq.it.cms.common.Servlets;
import com.zq.it.cms.domain.Role;
import com.zq.it.cms.service.RoleService;

/**
 * @author zhengqiang
 * 2018-10-20下午2:19:26
 * @description 角色管理
 */
@Controller
@RequestMapping("/role")
public class RoleController {
	
	@Autowired
	private RoleService roleService;
	
	@RequestMapping(value = "/list")
	public String list(ModelMap model){
		Map<String, Object> params = Servlets.getSearchParam();
		PageRequest page = Servlets.getPageRequest();
		Page<Role> pageData = roleService.findPageByParams(params, page);
		model.put("pageData", pageData);
		return "role/list";
	}
	@RequestMapping(value = "/create")
	public String create(ModelMap model){
		return "role/form";
	}
	@RequestMapping(value = "/edit")
	public String edit(ModelMap model){
		return "role/form";
	}
	@RequestMapping(value = "/save", method = RequestMethod.POST)
	public String save(Role role, ModelMap model){
		return "redirect:create";
	}
	@RequestMapping(value = "/delete")
	public String delete(ModelMap model){
		return "redirect:list";
	}
	
}
